#!/usr/bin/env echo "no"
# utf-8

me=start
W=$HOME/$me

IS_UBUNTU=false;
[[ `uname -rv` =~ Ubuntu ]] && IS_UBUNTU=true;

YUM="yum"
$IS_UBUNTU && YUM="apt-get"

function install {
  sudo $YUM install -y $@
}

### START ###
{
  cmd=git
  hash $cmd 2>/dev/null || {
    echo "install git"
    set -e
    $install $ins
    set +e
  }

  echo "init start"
  dir=$W
  url="https://coding.net/hontlong/start.git"
  [ -d $dir -a -d $dir/.git ] && { 
    cd $dir;
    git pull
  } || {
    [[ -f $dir ]] && { 
      echo "$dir is exists"; 
      exit 1; 
    }
    [[ -d $dir ]] && rmdir $dir
    set -e
    git clone $url $dir
    set +e
  }
  echo "init OK"
}

cd $W

source ./lib.sh

need curl
need wget
need grep

sed -i 's/^enabled=1/enabled=0/' /etc/yum/pluginconf.d/fastestmirror.conf
curl http://oss.aliyuncs.com/aliyunecs/update_source.tgz|tar -xzv -O|sudo bash >/dev/null

need vim
base_to_home .vimrc
base_to_home .bash_profile
git_sync ~/.vim/bundle/Vundle.vim https://github.com/gmarik/Vundle.vim.git 
run "安装 Vim 插件" "true" vim +PluginInstall +qall

base_to_home bin

need openssl
myrepos
need rz lrzsz
need sz lrzsz
need tmux
need zip
need unzip

mkdir -p ~/download ~/local ~/bin ~/develop ~/apps

echo "All IS OK"

